From f7c1a9cd63c03f6f5843c0e918c445303d861d94 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 12 Oct 2005 09:33:03 +0100 Subject: [PATCH] This patch implements select() functionality on /dev/vtpm and fixes some other problems. Signed-off-by: Stefan Berger --- linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c | 10 ++++++++-- linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c index f5c0ccb10a..0a8d70528c 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -680,9 +681,14 @@ vtpm_op_release(struct inode *inode, struct file *file) } static unsigned int -vtpm_op_poll(struct file *file, struct poll_table_struct *pst) +vtpm_op_poll(struct file *file, struct poll_table_struct *pts) { - return 0; + unsigned int flags = POLLOUT | POLLWRNORM; + poll_wait(file, &dataex.wait_queue, pts); + if (!list_empty(&dataex.pending_pak)) { + flags |= POLLIN | POLLRDNORM; + } + return flags; } static struct file_operations vtpm_ops = { diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c index 09ffb02002..9276c19354 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -372,7 +373,7 @@ again: info->watch.callback = watch_for_status; err = register_xenbus_watch(&info->watch); if (err) { - message = "registering watch on backend"; + xenbus_dev_error(dev, err, "registering watch on backend"); goto destroy_tpmring; } @@ -398,6 +399,8 @@ static int tpmfront_probe(struct xenbus_device *dev, int err; struct tpmfront_info *info; int handle; + int len = max(XS_WATCH_PATH, XS_WATCH_TOKEN) + 1; + const char *vec[len]; err = xenbus_scanf(NULL, dev->nodename, "handle", "%i", &handle); @@ -427,6 +430,10 @@ static int tpmfront_probe(struct xenbus_device *dev, return err; } + vec[XS_WATCH_PATH] = info->watch.node; + vec[XS_WATCH_TOKEN] = NULL; + watch_for_status(&info->watch, vec, len); + return 0; } -- 2.30.2